/*
	This file is part of Vajolet.

    Vajolet is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Vajolet is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Vajolet.  If not, see <http://www.gnu.org/licenses/>
*/

#ifndef _EVAL
#define _EVAL
extern int pawnEndgameBonusPst;
extern int bishopPairBonusOpening;
extern int bishopPairBonusEndgame;
extern int bishopPairBonus2Opening;
extern int bishopPairBonus2Endgame;
extern int bishopRedundancyPenaltyOpening;
extern int bishopRedundancyPenaltyEndgame;
extern int rookRedundancy1Opening;
extern int rookRedundancy1Endgame;
extern int rookRedundancy2Opening;
extern int rookRedundancy2Endgame;
extern int knightRedundancyOpening;
extern int knightRedundancyEndgame;
extern int rookPawnCountOffset;
extern int rookPawnCountMalusOp;
extern int rookPawnCountMalusEnd;
extern int knightPawnCountOffset;
extern int knightPawnCountMalusOp;
extern int knightPawnCountMalusEnd;


extern int isolatedPawnPenaltyOpening[2][8];
extern int isolatedPawnPenaltyEndgame[2][8];
extern int doubledPawnPenaltyOpening[2];
extern int doubledPawnPenaltyEndgame[2];
extern int chainedPawnBonusOpening[8];
extern int chainedPawnBonusEndgame[8];

extern int passedPawnBonusOpening;
extern int passedPawnBonusEndgame;

extern int backwardPawnPenaltyOpening[8];
extern int backwardPawnPenaltyEndgame[8];

extern int spaceWeight;
extern int passedPawnPenaltyFileAH;
extern int passedPawnSupportedBonus;
extern int passedPawnNonBlockedBonus;

extern int candidateBonusOpening;
extern int candidateBonusEndgame;

extern int knightOutpostBonus; 
extern int bishopOutpostBonus;


/*extern int bishopThreathOpening;
extern int bishopThreathEndgame;
extern int knightThreathOpening;
extern int knightThreathEndgame;
extern int rookThreathOpening;
extern int rookThreathEndgame;
extern int queenThreathOpening;
extern int queenThreathEndgame;

extern int bishopUndefendedOpening;
extern int bishopUndefendedEndgame;
extern int knightUndefendedOpening;
extern int knightUndefendedEndgame;
extern int rookUndefendedOpening;
extern int rookUndefendedEndgame;
extern int queenUndefendedOpening;
extern int queenUndefendedEndgame;*/

extern int undefendedMinorPenalty;
extern int threatPenalty[8];



extern float knightMobOpA;
extern float knightMobOpM;
extern float knightMobOpQ;
extern float knightMobOp0;

extern float knightMobEnA;
extern float knightMobEnM;
extern float knightMobEnQ;
extern float knightMobEn0;

extern float bishopMobOpA;
extern float bishopMobOpM;
extern float bishopMobOpQ;
extern float bishopMobOp0;

extern float bishopMobEnA;
extern float bishopMobEnM;
extern float bishopMobEnQ;
extern float bishopMobEn0;

extern float rookMobOpA;
extern float rookMobOpM;
extern float rookMobOpQ;
extern float rookMobOp0;

extern float rookMobEnA;
extern float rookMobEnM;
extern float rookMobEnQ;
extern float rookMobEn0;

extern float queenMobOpA;
extern float queenMobOpM;
extern float queenMobOpQ;
extern float queenMobOp0;

extern float queenMobEnA;
extern float queenMobEnM;
extern float queenMobEnQ;
extern float queenMobEn0;


extern int rookOn7Opening;
extern int rookOn7Endgame;
extern int queenOn7Opening;
extern int queenOn7Endgame;
extern int rookOnPawnOpening;
extern int rookOnPawnEndgame;
extern int queenOnPawnOpening;
extern int queenOnPawnEndgame;

extern int rookOnOpenOpening;
extern int rookOnOpenPawnEndgame;
extern int rookOnSemiOpening;
extern int rookOnSemiPawnEndgame;


extern int KingNearOwnPassedPawnBonus;
extern int KingNearEnemyPassedPawnBonus;
extern int kingShieldBonus[4];
extern int kingSafetyEval[];

extern int badBishopOpening;
extern int badBishopEndgame;

extern int knightMobBonusOp[32];
extern int knightMobBonusEn[32];
extern int bishopMobBonusOp[32];
extern int bishopMobBonusEn[32];
extern int rookMobBonusOp[32];
extern int rookMobBonusEn[32];
extern int queenMobBonusOp[32];
extern int queenMobBonusEn[32];

extern int littleCenterControlOpening;
extern int bigCenterControlOpening;

extern int kingSafety0,kingSafety1,kingSafety2;

inline int makeScore(int mg, int eg) { return int((mg << 16) + eg); }
inline int mg_value(int s) { return int(((s + 32768) & ~0xffff) / 0x10000); }

inline int eg_value(int s) {
  return int((int)(unsigned(s) & 0x7fffu) - (int)(unsigned(s) & 0x8000u));
}

#endif
